package com.yupi.springbootinit.mapper;

import com.yupi.springbootinit.model.entity.Attachment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @author MR
* @description 针对表【attachment(附件表)】的数据库操作Mapper
* @createDate 2025-08-04 19:22:22
* @Entity com.yupi.springbootinit.model.entity.Attachment
*/
@Mapper
public interface AttachmentMapper extends BaseMapper<Attachment> {
    // 1. 新增附件
    int insert(Attachment attachment);

    // 2. 按ID查询单个附件
    Attachment selectById(@Param("id") Long id);

    // 3. 按业务类型和业务ID查询所有附件
    List<Attachment> selectByBizTypeAndBizId(@Param("bizType") String bizType, @Param("bizId") Long bizId);

    // 4. 按业务类型、业务ID、文件分类查询
    List<Attachment> selectByBizTypeAndBizIdAndFileCategory(@Param("bizType") String bizType, @Param("bizId") Long bizId, @Param("fileCategory") String fileCategory);

    // 5. 按业务类型、业务ID、文件分类、节点查询
    List<Attachment> selectByBizTypeAndBizIdAndFileCategoryAndNode(@Param("bizType") String bizType, @Param("bizId") Long bizId, @Param("fileCategory") String fileCategory, @Param("node") String node);

    // 6. 更新附件（如软删除、更新备注等）
    int update(Attachment attachment);

    // 7. 批量删除（可选）
    int batchDelete(@Param("ids") List<Long> ids, @Param("deletedBy") Long deletedBy);

    // 8. 批量插入（可选）
    int batchInsert(@Param("attachments") List<Attachment> attachments);
}




